const fs = require("fs");
const path = require("path");

let dirPath = path.join(__dirname,"test");
function delDir(folderPath){
    let list = fs.readdirSync(folderPath);
    for(let i =0;i<list.length;i++){
        /**需要拿到文件夹中子文件或子文件夹的路径 */
        let childPath = path.join(dirPath,list[i]);
        let fileObj = fs.statSync(childPath);
        if(fileObj.isDirectory()){
            delDir(childPath);
        }
        else if(fileObj.isFile()){
            fs.unlinkSync(childPath);
        }

    }
}
delDir(folderPath);